package com.google.code.stalkernet.async.io;

import java.nio.ByteBuffer;
import java.nio.channels.ScatteringByteChannel;

import com.google.code.stalkernet.async.Async;

/**
 * Asynchronous version of {@link ScatteringByteChannel} interface.
 *
 * @author Mikhail Vladimirov
 */
public interface AsyncScatteringByteChannel
    extends Async, AsyncReadableByteChannel
{
    /**
     * Asynchronous version of {@link ScatteringByteChannel#read(ByteBuffer[],
     * int, int)}.
     *
     * @param dsts The buffers into which bytes are to be transferred
     * @param offset The offset within the buffer array of the first buffer into
     *        which bytes are to be transferred; must be non-negative and no
     *        larger than <tt>dsts.length</tt>
     * @param length The maximum number of buffers to be accessed; must be
     *        non-negative and no larger than
     *        <tt>dsts.length</tt>&nbsp;-&nbsp;<tt>offset</tt>
     * @param callback callback to receive asynchronous operation result
     * @return asynchronous operation handle
     */
    public Handle read(
        ByteBuffer[] dsts, int offset, int length, Callback <Long> callback);

    /**
     * Asynchronous version of {@link ScatteringByteChannel#read(ByteBuffer[])}.
     *
     * @param dsts The buffers into which bytes are to be transferred
     * @param callback callback to receive asynchronous operation result
     * @return asynchronous operation handle
     */
    public Handle read(ByteBuffer[] dsts, Callback <Long> callback);
}
